Use your 50 M and make a probe. Send it to gather when it is done. Make another probe and scoot it out to warp in a pylon and then make it gather minerals. Make another probe (this the 3rd one you made) and scoot it out to warp in a gateway --- the pylon should come in right when the probe is finished. Then leave the probe there until you have enough minerals to warp in a 2nd gateway. When you have started the rift for your second gateway, send that probe to gather. Continue making probes until the gateways come in. Then create one zealot from each. When you have enough minerals, send a probe back out to warp in two new pylons at both sides of your entrance:
Then get a forge. All this time you should have been getting zealots. When the forge comes in, start to get some cannons (about 3-6 on each side). I prefer to get less cannons (3) so it won't get crowded. Then build batteries in front of your cannons on each side: (4-6).
Make sure to leave room for any big units like dragoons and archons to get through. Just continue to go up the tech tree after this. Your defense should be something like this:
Make good notice of those templar. Oh yeah, in case you don't know how to use shield batteries, just click on them, press on your keyboard "r," and click anywhere near your units. Whoever needs it will come forward and get recharged. Here how you use your defense: when attacked psi storm them. Very simple. If you don't have templar yet or have run out of magic, use your units like shown the picture above with the cannons as back-up. Recharge often in mid battle. When your base is fully developed, it should have 8 starcgates, 4 gateways, 2 robotics facilities, and one of every other building. Try not to stack your pylons, put them in places where they support your building. If you need to get more pylons, just keep putting them as near the buildings as possible. Also, put cannons everywhere in your base. Dont't stack them in your base but put them here and there esp. near your nexus. Later, my primary attack force is this:
This is a picture of 4 arbiters, 12 carriers, and 2 observers. One last thing, get a lot of probes. This is usually what I get: